The garbage collector of KCL has three levels according to what it collects:
In levels 2 and 3, the relocatable area is shifted to the higher address space to reserve an appropriate number of pages in the hole.
For each type class, KCL keeps a free list of unused cells, and when the free list is exhausted, a new page is allocated, or the garbage collector is invoked, depending on whether the maximum number of pages for that class have been allocated or not.
The garbage collector does not compactify the heap. That is, cells and contiguous blocks are never moved to another place. Moreover, once a page is allocated for a particular type class or for contiguous blocks, that page will never be freed for other classes, even if the entire page becomes garbage.
On the other hand, the relocatable area is compactified during level 2 and level 3 of garbage collection. A relocatable block is really relocatable.
The garbage collector is automatically invoked in one of the following situations. The number in the parentheses indicates the level of garbage collection that is performed.
The garbage collector is also invoked by the following KCL specific function.
gbc x[Function]